﻿
using strange.extensions.mediation.impl;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;


/// <summary>
/// 开始面板的View类
/// </summary>
public class StartView : EventView
{
    private Button But_One;
    private Button But_Two;

    /// <summary>
    /// 开始面板初始化
    /// </summary>
    public void Init()
    {
        But_One = transform.Find("But_One").GetComponent<Button>();
        But_Two = transform.Find("But_Two").GetComponent<Button>();
        //注册事件
        But_One.onClick.AddListener(OnBut_OneClick);
        But_Two.onClick.AddListener(OnBut_TwoClick);
    }
    /// <summary>
    /// 面板销毁
    /// </summary>
    public void OnViewDestroy()
    {
        //注销事件
        But_One.onClick.RemoveListener(OnBut_OneClick);
        But_Two.onClick.RemoveListener(OnBut_TwoClick);
    }
    /// <summary>
    /// 一倍按钮点击
    /// </summary>
    private void OnBut_OneClick()
    {
        //更改Integration = 1
        dispatcher.Dispatch(ViewEvent.View_ChangeMultiple, 1);
        //销毁面板
        Destroy(gameObject);
    }
    /// <summary>
    /// 二倍按钮点击
    /// </summary>
    private void OnBut_TwoClick()
    {
        //更改Integration = 2
        dispatcher.Dispatch(ViewEvent.View_ChangeMultiple, 2);
        //销毁面板
        Destroy(gameObject);
    }
}
